//
//  StationListPopViewController.m
//  Runone
//
//  Created by runone01 on 16/10/10.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "StationListPopViewController.h"
#import "AppDelegate.h"
#import "StationModel.h"

@interface StationListPopViewController ()

@end

@implementation StationListPopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.preferredContentSize=CGSizeMake(150, 200);
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"LineCell"];
    self.tableView.bounces = NO;
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    AppDelegate *myDelegate = (AppDelegate*) [UIApplication sharedApplication].delegate;
    return myDelegate.AllTollStationArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     AppDelegate *myDelegate = (AppDelegate*) [UIApplication sharedApplication].delegate;
    static NSString *CellID=@"LineCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath];
    if (cell==nil) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
    }
    StationModel *model = myDelegate.AllTollStationArray[indexPath.row];
    cell.textLabel.text = [NSString stringWithFormat:@"%@",model.TollStationName];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     AppDelegate *myDelegate = (AppDelegate*) [UIApplication sharedApplication].delegate;
    if (self.LineBlock!=nil) {
        self.LineBlock(myDelegate.AllTollStationArray[indexPath.row]);
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
